package com.jiazhong.boot.mvc.interceptor.filter;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Slf4j
@WebFilter("/*")
@Component
public class SecondFilter extends HttpFilter implements Ordered {

    @Override
    public int getOrder() {
        return 56;
    }

    @Override
    protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
        log.info("This is SecondInterceptor doFilter");
        chain.doFilter(request, response);
        log.info("This is SecondInterceptor doFilter");
    }
}
